package com.zbiti.anvil.basic.admin.gateway.selenium.page.system;

import com.zbiti.anvil.basic.admin.gateway.selenium.util.ElementUtils;

/**
 * 系统用户管理测试
 *
 * @author Fanyc
 * @date 2021-05-13 17:02
 */
public class SystemUserTester {

    /**
     * 查询结果测试
     *
     * @throws InterruptedException Sleep异常
     */
    public void searchTest() throws InterruptedException {
        ElementUtils.console(">> 验证第一页查询结果");
        // 验证查询结果数据是否正确
        final String tBodyXpath = "/html/body/div[1]/div/div[2]/section/div/div[1]/div[2]/div[2]/div[3]/table/tbody";

        // 验证登录账户，顺序需要与数据库一致
        ElementUtils.assertTableColumnResult(null, tBodyXpath, 3, new String[]{"anvil", "config_anvil", "js_anvil", "js_manager", "js_user", "yfb_anvil", "yfb_manager", "yfb_user", "zxb_anvil", "zj_user1"});

        // 2.点击下一页
        ElementUtils.console(">> 验证第二页查询结果");
        ElementUtils.clickByXpath(null, "/html/body/div[1]/div/div[2]/section/div/div[1]/div[2]/div[3]/div/ul/li[2]");
        // 遮罩显示后再消失消失
        ElementUtils.waitInvisibility(ElementUtils.xpath(null,"/html/body/div[1]/div/div[2]/section/div/div[1]/div[2]/div[2]/div[5]"));
        // 验证登录账户
        ElementUtils.assertTableColumnResult(null, tBodyXpath, 3, new String[]{"zj_user2", "yfb1_user", "yfb2_user"});

        // 3.条件参数查询
        ElementUtils.sendKeysByXpath(null, "/html/body/div[1]/div/div[2]/section/div/div/div[2]/form/div[1]/div/div/input", "anvil");
        ElementUtils.sendKeysByXpath(null, "/html/body/div[1]/div/div[2]/section/div/div/div[2]/form/div[2]/div/div/input", "负责人");

        ElementUtils.clickByXpath(null, "/html/body/div[1]/div/div[2]/section/div/div/div[2]/form/div[5]/div/button[1]");
        // 遮罩显示后再消失消失
        ElementUtils.waitInvisibility(ElementUtils.xpath(null,"/html/body/div[1]/div/div[2]/section/div/div[1]/div[2]/div[2]/div[5]"));
        // 验证结果
        ElementUtils.assertTableColumnResult(null, tBodyXpath, 3, new String[]{"js_anvil", "yfb_anvil", "zxb_anvil"});
        // 重置查询
        ElementUtils.clickByXpath(null, "/html/body/div[1]/div/div[2]/section/div/div[1]/div[2]/form/div[5]/div/button[2]");
        // 遮罩显示后再消失消失
        ElementUtils.waitInvisibility(ElementUtils.xpath(null,"/html/body/div[1]/div/div[2]/section/div/div[1]/div[2]/div[2]/div[5]"));
    }
}
